﻿using System;
using System.Text;
using Microsoft.Practices.Unity;

namespace CacheAspect
{
    public static class CacheService
    {
        static CacheService()
        {
            if (Cache == null)
            {
                try
                {
                    //this is not working??
                    Cache = Unity.Resolve<ICache>();
                }
                catch
                {
                    //if a cache is not configured, fall back on NoCache 
                    //this happens in test cases if unity is not setup
                    //Cache = new NoCache();

                    Cache = new InProcessMemoryCache();
                }
            }
        }

        public static ICache Cache;
        public static IUnityContainer Unity = new UnityContainer();
    }
}
